package com.zwj.converter;

import com.mysql.cj.util.StringUtils;
import org.springframework.core.convert.converter.Converter;

import java.text.SimpleDateFormat;
import java.util.Date;

public class MydateConverter implements Converter<String, Date> {
    @Override
    public Date convert(String s) {
        if (StringUtils.isNullOrEmpty(s)){
            throw new RuntimeException("输入的参数为空！！");
        }
        try {
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
            // 返回解析后的字符串
            return sf.parse(s);
        }catch (Exception e){
            throw new RuntimeException("类型转换错误！！");
        }

    }
}
